package com.sino.controller;

import com.sinoframework.io.CommonInputStreamResource;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.core.ParameterizedTypeReference;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource;
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
import org.springframework.core.io.support.ResourcePatternResolver;
import org.springframework.http.*;
import org.springframework.util.ClassUtils;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.InputStream;
import java.util.List;

/**
 * @title: ResourseLoadController
 * @Author Qiulei
 * @Date: 2023/11/23 13:25
 */
@RestController
@RequestMapping("/sino/restTemplate")
public class RestTemplateController {
    private static final Logger log = LogManager.getLogger();
    @RequestMapping(value="test",produces = MediaType.APPLICATION_JSON_VALUE)
    public Object testRt() {
        InputStream inputStream = null;

        HttpHeaders headers2 = new HttpHeaders();
        headers2.setContentType(MediaType.MULTIPART_FORM_DATA);
        MultiValueMap<String, Object> params2 = new LinkedMultiValueMap<>();
        Resource resource = new CommonInputStreamResource(inputStream);
        params2.add("img_file", resource);
        HttpEntity httpEntity2 = new HttpEntity(params2, headers2);

//        ParameterizedTypeReference<Result<List<SubPicturePoints>>> subTypeRef2 = new ParameterizedTypeReference<Result<List<SubPicturePoints>>>() {};
//        ResponseEntity<Result<List<SubPicturePoints>>> subExchange = restTemplate.exchange("http://192.168.0.247:9347/ocr"
//                , HttpMethod.POST
//                , httpEntity2
//                , subTypeRef2);
        return "加载classpath下文件成功";
    }



}
